<img id="img" onclick="playOrStop()" src="1.jpg">
<script>
    var i = 1;
    var j = 1;
    function lunhuan(){
        i++;
        if(i==7) i = 1;
        img.src = i+".jpg";
    }
  var timer=setInterval(lunhuan,300);
  function playOrStop(){
    if(j==1){
      clearInterval(timer);
      j=0;
    }else{
      timer=setInterval(lunhuan,300);
      j=1;
    }
  }
</script>